<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>

<!DOCTYPE html>
<!--[if IE 8]>
<html xmlns="http://www.w3.org/1999/xhtml" class="ie8" lang="zh-CN">
<![endif]-->
<!--[if !(IE 8) ]><!-->
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
<!--<![endif]-->
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>${options.optionSiteTitle} &lsaquo; 登录</title>
    <link rel="stylesheet" href="/plugin/font-awesome/css/font-awesome.min.css">
    <link rel="shortcut icon" href="/img/logooo.png">
    <link rel='stylesheet' id='dashicons-css'  href='/plugin/login/dashicons.min.css' type='text/css' media='all' />
    <link rel='stylesheet' id='buttons-css'  href='/plugin/login/buttons.min.css' type='text/css' media='all' />
    <link rel='stylesheet' id='forms-css'  href='/plugin/login/forms.min.css' type='text/css' media='all' />
    <link rel='stylesheet' id='l10n-css'  href='/plugin/login/l10n.min.css' type='text/css' media='all' />
    <link rel='stylesheet' id='login-css'  href='/plugin/login/login.min.css' type='text/css' media='all' />
    <style type="text/css">
        body {
            font-family: "Microsoft YaHei", Helvetica, Arial, Lucida Grande, Tahoma, sans-serif;
            background: url(/img/loginBgg.jpg);
            width:100%;
            height:100%;
        }

        .login {
            max-width: 400px;
            margin: 0 auto;
            background-color: #fff;
            border-radius: 5px;
            box-shadow: 0 0 10px rgba(0,0,0,0.2);
            padding: 20px;
        }

        .login h1 {
            text-align: center;
            color: #444;
            margin-bottom: 30px;
        }

        .login form{
            opacity: 0.8;
            background: #fff;
            background: rgba(255, 255, 255, 0.6);
            border: 1px solid #fff;
            border-radius: 2px;
        }

        .login label {
            display: block;
            margin-bottom: 10px;
            color: #444;
            font-weight: bold;
        }

        .login input[type="text"], .login input[type="password"] {
            height:30px;
            width: 100%;
            padding: 10px;
            border-radius: 5px;
            border:none;
            border-bottom:2px solid #eee;
            margin-bottom: 20px;
        }

        .login input[type="checkbox"] {
            margin-top: 10px;
            margin-right: 5px;
            vertical-align: middle;
        }

        .login p.submit {
            text-align: center;
            width:150%;
            height:150%;
        }

        .login input[type="submit"] {
            background-color: #4CAF50;
            color: #fff;
            border: none;
            padding: 5px 15px 9px 15px;
            border-radius: 5px;
            cursor: pointer;
            font-size: 10px;
        }

        .login input[type="submit"]:hover {
            background-color: #3e8e41;
        }

        .login p.error {
            color: #ff0000;
            margin-top: 20px;
            text-align: center;
        }
        #backtoblog a, #nav a {
            color: #fff !important;
        }
    </style>

    <meta name='robots' content='noindex,follow' />
    <meta name="viewport" content="width=device-width" />
    <style>
        body {
            background-repeat: no-repeat;
            background-size: 100% 100%;
            background-attachment: fixed;
        }
    </style>
</head>
<body class="login login-action-login wp-core-ui  locale-zh-cn">
<div id="login">
    <h1><a href="/" title="欢迎您光临本站！" tabindex="-1">${options.optionSiteTitle}</a></h1>
    <%
        String username = "";
        String password = "";
        //获取当前站点的所有Cookie
        Cookie[] cookies = request.getCookies();
        for (int i = 0; i < cookies.length; i++) {//对cookies中的数据进行遍历，找到用户名、密码的数据
            if ("username".equals(cookies[i].getName())) {
                username = cookies[i].getValue();
            } else if ("password".equals(cookies[i].getName())) {
                password = cookies[i].getValue();
            }
        }
    %>
    <div class="login">
        <h1>登录</h1>
        <form name="loginForm" id="loginForm" method="post">
            <label for="user_login">用户名或电子邮件地址:</label>
            <input style="border-top:0;border-left:0;border-right:0" type="text" name="username" id="user_login" class="input" value="" size="20" required/>
            <label for="user_pass">密码:</label>
            <input style="border-top:0;border-left:0;border-right:0" type="password" name="password" id="user_pass" class="input" value="" size="20" required/>
            <label>
                <input name="rememberme" type="checkbox" id="rememberme"  style="vertical-align:middle;" value="1" checked />
                <sapn style="vertical-align:middle;">记住密码</sapn>
            </label>
            <p class="submit">
                <input type="submit" name="wp-submit" id="submit-btn" class="button button-large" value="登录"  />
            </p>
        </form>
    </div>



    <script type="text/javascript">
        function wp_attempt_focus(){
            setTimeout( function(){ try{
                d = document.getElementById('user_login');
                d.focus();
                d.select();
            } catch(e){}
            }, 200);
        }

        wp_attempt_focus();
        if(typeof wpOnload=='function')wpOnload();
    </script>
    <p id="backtoblog"><a href="/">&larr; 返回到风吟博客</a> | <a href="/register">注册</a></p>

</div>


<div class="clear"></div>

<script src="/js/jquery.min.js"></script>
<script type="text/javascript">


    <%--登录验证--%>
    $("#submit-btn").click(function () {
        var user = $("#user_login").val();
        var password = $("#user_pass").val();
        if(user=="") {
            alert("用户名不可为空!");
        } else if(password==""){
            alert("密码不可为空!");
        } else {
            $.ajax({
                async: false,//同步，待请求完毕后再执行后面的代码
                type: "POST",
                url: '/loginVerify',
                contentType: "application/x-www-form-urlencoded; charset=utf-8",
                data: $("#loginForm").serialize(),
                dataType: "json",
                success: function (data) {
                    if(data.code==0) {
                        alert(data.msg);
                    } else {
                        window.location.href="/admin";

                    }
                },
                error: function () {
                    alert("数据获取失败")
                }
            })
        }
    })

</script>
</body>
</html>